package com.frxuexi.shop.adapter

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.Item0
import com.frxuexi.lib_base.entity.OrderBean
import com.frxuexi.lib_base.utils.GlideUtils
import com.frxuexi.shop.R
import com.frxuexi.shop.databinding.ItemOrderBinding
import com.frxuexi.shop.databinding.ItemOrderDfhBinding
import com.frxuexi.shop.databinding.ItemOrderDplBinding
import com.frxuexi.shop.databinding.ItemOrderDshBinding

class OrderAdapter:BaseMultiItemQuickAdapter<Item0,BaseViewHolder>() {
    init {
        addItemType(0,R.layout.item_order)
        addItemType(1,R.layout.item_order_dfh)
        addItemType(2,R.layout.item_order_dsh)
        addItemType(3,R.layout.item_order_dpl)
        addItemType(4,R.layout.item_order_dpl)
        addItemType(5,R.layout.item_order_dpl)
    }

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemOrderBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: Item0) {
        when(item.itemType){
            0->{
                val binding = DataBindingUtil.getBinding<ItemOrderBinding>(helper.itemView)!!
                binding.bean=item
                GlideUtils.loadRoundImage(item.orderInfoList[0].image,binding.orderIv)
            }
            1->{
                val binding = DataBindingUtil.getBinding<ItemOrderDfhBinding>(helper.itemView)!!
                binding.bean=item
                GlideUtils.loadRoundImage(item.orderInfoList[0].image,binding.orderIv)
            }
            2->{
                val binding = DataBindingUtil.getBinding<ItemOrderDshBinding>(helper.itemView)!!
                binding.bean=item
                GlideUtils.loadRoundImage(item.orderInfoList[0].image,binding.orderIv)
            }
            3,4,5->{
                val binding = DataBindingUtil.getBinding<ItemOrderDplBinding>(helper.itemView)!!
                binding.bean=item
                GlideUtils.loadRoundImage(item.orderInfoList[0].image,binding.orderIv)
            }
        }
    }

}